package 课本编程题;

public class 课本编程题 {
	public interface Ani{
	    void cry();
        String getAnimalName();
	}
	
	public class Simulator {
		public void playSound(Ani animal){
			System.out.print("正在放"+animal.getAnimalName()+"类的声音:");
			animal.cry();
		}
	}
	public class Dog implements Ani {
		public void cry() {
			System.out.print("wang wang...wang wang");
		}
		public String getAnimalName() {
			return "dog";
		}
	}
	public class Cat implements Ani {
		public void cry(){
			System.out.println("meow meow...meow meow");
		}
		public String getAnimalName() {
			return "cat";
		}
	}
	public class Application{
		public static void main (String[] ages ) {
			Simulator simulator = new Simulator();
			simulator.playSound(new Dog());
			simulator.playSound(new Cat());
		}
	}



}
